package splatform.webchatbot.quartz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * Created by Administrator on 2017/3/4.
 * 检查死亡的机器人，并清理它们
 */
public class CheckDeadBot {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void execute() {
        //删除心跳停止的机器人,超过10秒没有反应的机器人,都会被停止
        String sql = " update bot set status = 0 , op = '' where last_heartbeat < DATE_SUB(NOW(), INTERVAL 10 SECOND) and status != 0 ";
        jdbcTemplate.execute(sql);
    }

}